package com.mc.lp.shared.vo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

import org.springframework.util.CollectionUtils;
/**
 * add multiple properties into search criteria. all would be applied using and
 * TODO extends this class to add criteria
 * @author deepak
 * @param <E>
 * @param <E>
 *
 */
public class KeyValueMap {
	HashMap<String, Object> keyValueMap= new HashMap<String, Object>();
	public KeyValueMap addKeyValue(String key, Object value){
		this.keyValueMap.put(key, value);
		return this;
	}
	
	public boolean isNotEmpty(){
		return !CollectionUtils.isEmpty(this.keyValueMap);
	}
	
	public ArrayList<KeyValue> getKeyValues(){
		 assert isNotEmpty();
		 ArrayList<KeyValue> keyValues= new ArrayList<KeyValue>();
		 for(Entry<String, Object> key: this.keyValueMap.entrySet()){
			 keyValues.add(new KeyValue(key.getKey(), key.getValue()));
		 }
		 return keyValues;
	}
}
